﻿<%@page import="com.sinba.common.utils.TranType"%>
<%@page import="com.sinba.common.dto.PageDTO"%>
<%@page import="com.sinba.common.system.dto.TransactionRecordDTO"%>
<%@page import="com.sinba.common.system.service.ITransactionRecordService"%>
<%@page import="com.sinba.common.user.dto.AccountDTO"%>
<%@page import="com.sinba.common.user.service.IAccountService"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="../language.jsp" %>
<%
if(session.getAttribute("password2")==null){
	response.sendRedirect( "login2.jsp?pageUrl=user/rechargeMain.jsp");
	return;
}

ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
ITransactionRecordService transactionRecordService = (ITransactionRecordService)ac.getBean("transactionRecordService");
TransactionRecordDTO trDTO = new TransactionRecordDTO();
trDTO.setLoginName((String)session.getAttribute("loginName"));
int pages = 1;
String sidx = "recordId";
String sord="desc";
if(request.getParameter("pages")!=null && request.getParameter("_pages")!=""){
	pages = Integer.parseInt(request.getParameter("pages"));
}
int rows = 10;
int start = ( pages - 1 ) * rows;
trDTO.setStart( start );
trDTO.setLimit( rows );
trDTO.setTransactionTypes(new String[]{TranType.ChongZhi,TranType.KouChu});
trDTO.setSearchType("Dynamic");
if(request.getParameter("trDTO.transactionType")!=null && request.getParameter("trDTO.transactionType")!=""){
	trDTO.setTransactionType(request.getParameter("trDTO.transactionType"));
	pages=1;
}
trDTO.setDtype("Dynamic");
PageDTO pageDTO = transactionRecordService.findTransactionRecordPager(trDTO, sord, sidx);
if(pageDTO!=null){
	pageDTO.setPage( pages );
	pageDTO.setRows( rows );
}
request.setAttribute("pageDTO",pageDTO);

//查询余额
Double rechargeBalance = transactionRecordService.findUserBalance(session.getAttribute("loginName").toString(),"Dynamic");
request.setAttribute("rechargeBalance",rechargeBalance);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title><fmt:message key="i18n.czManage"/>-<fmt:message key="i18n.title"/> </title>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1" />

<!-- Bootstrap framework -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css" />
    <link rel="stylesheet" href="bootstrap/css/bootstrap-responsive.min.css" />
<!-- breadcrumbs-->
	<link rel="stylesheet" href="lib/jBreadcrumbs/css/BreadCrumb.css" />
<!-- main styles -->
    <link rel="stylesheet" href="css/sub_page_main_style.css" />

<!--[if lte IE 8]>
    <link rel="stylesheet" href="css/ie.css" />
    <script src="js/ie/html5.js"></script>
    <script src="js/ie/respond.min.js"></script>
<![endif]-->


</head>
<body style="height:800px">
<!-- 主体内容 -->
<div id="contentwrapper">
	<div class="main_content">
		 <nav>
            <div id="jCrumbs" class="breadCrumb module">
                <ul>
                    <li>
                        <a href="main.jsp"><i class="icon-home"></i></a>
                    </li>
                    <li>
                        <a href="#"><fmt:message key="i18n.moneyManage"/></a>
                    </li>
                    <li>
                        <a href="#"><fmt:message key="i18n.czManage"/></a>
                    </li>
                </ul>
            </div>
         </nav>
         
         <h3 class="heading"><fmt:message key="i18n.dyBalance"/>：<span style="color:red;"><fmt:formatNumber value="${rechargeBalance}" pattern="#0.0000"/></span></h3>   
	
   		 <div class="listCont">
    		<div>
    			<h3 class="heading"><fmt:message key="i18n.onlineCz"/></h3>
				<div style="font-weight: 600;color: red;"></div>
				<div>${ resultStr }</div>
				
				<form action="orderPage.jsp" method="post" >
				<input type="hidden" name="pageUrl" value="rechargeMain.jsp" />
				<table>
					<tr>
						<td>
							<fmt:message key="i18n.czMoney"/>：
							<input name="payMoeny" id="pay_toMoeny"  onkeyup="toRmb()" />
							<input onClick="return checkformPay();" type=submit name="submit" value=" <fmt:message key="i18n.confimCz"/>  " />
							<span id="show_toRmb" style="color: red;"></span>
							
						</td>
					</tr>
				</table>
				</form>
				
				<%-- 
				<form action="registerUser!rechargeToDs.action" method="post" >
				<input type="hidden" name="pageUrl" value="rechargeMain.jsp" />
				<input type="hidden" name="loginName" value="${session.loginName}" />
				<input type="hidden" name="dtype" value="ToDynamic" />
				<table>
					<tr>
						<td>
							<span style="font-weight: 600;"><fmt:message key="i18n.zhuanru"/>：</span>
							 <fmt:message key="i18n.zhuanruMoney"/>：<input name="moeny" id="toMoeny" />
							<input onClick="return checkform();" type=submit name="submit" value=" <fmt:message key="i18n.confimzhuanru"/>  " />
							
						</td>
					</tr>	
				</table>
				</form>--%>
				<h3 class="heading"><fmt:message key="title.historyRecord"/></h3>
				<form id="bonusSeachForm" action="rechargeMain.jsp" method="post">
				<input name="sidx" value="recordId" type="hidden" >
				<input name="sord" value="desc" type="hidden" >
				<input name="trDTO.searchType" value="bonus" type="hidden" >
				<input name="trDTO.loginName" value="${session.loginName }" type="hidden" >
				<table width="100%">
					<tr>
					 	<td>
					 	  <fmt:message key="i18n.type"/> <select name="trDTO.transactionType">
					 	   	<option value="">--<fmt:message key="i18n.pelaseSelect"/>--</option>
					 	   	<%-- <option value="转入报单钱包"><fmt:message key="i18n.zhuanru"/></option> --%>
					 	   	<option value="ChongZhi"><fmt:message key="i18n.cz"/></option>
					 	   	<option value="KouChu"><fmt:message key="i18n.kouchu"/></option>
					 	   </select>
					 	</td>
					 	<td>
					 		<fmt:message key="i18n.jiesuanData"/> <input name="trDTO.startTime" class="easyui-datebox"></input> <fmt:message key="i18n.to"/>  <input name="trDTO.endTime" class="easyui-datebox"/> 
					 		<a style="cursor: pointer;" id="doSeach"><input type="button" value="<fmt:message key="i18n.serach"/>" /></a>
					 	</td>
					</tr>
				</table>
				</form>    			
    		</div>
	    	<div class="listTable lttno">
					<table class="table table-bordered table-striped" id="smpl_tbl">
		        		<thead>
		        			
		        			<tr class="color1">
		        				<th><fmt:message key="i18n.type"/></th>
		        				<th><fmt:message key="i18n.income"/></th>
		        				<th><fmt:message key="i18n.zhichu"/></th>
		        				<th><fmt:message key="i18n.balance"/></th>
		        				<th><fmt:message key="i18n.operationTime"/></th>
		        				<th><fmt:message key="i18n.remark"/></th>
		        			</tr>
		        			
		        		</thead>
		        		<tbody>
		        			<c:forEach items="${pageDTO.data}" var="data">
		        				<tr>
		        					<td>
		        					<fmt:message key="${data.transactionType}"/>
		        					</td>
		        					<td><fmt:formatNumber value="${data.income}" pattern="#0.0000"/></td>
		        					<td><fmt:formatNumber value="${data.expenditure}" pattern="#0.0000"/></td>
		        					<td><fmt:formatNumber value="${data.balance}" pattern="#0.0000"/></td>
		        					<td><fmt:formatDate value="${data.optDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
		        					<td>${data.remark}</td>
		        				</tr>
		        			</c:forEach>
		        			<c:if test="${empty pageDTO.data}">
		        				<tr>
		        					<td colspan="6" align="center"><fmt:message key="i18n.noData"/>!</td>
		        				</tr>
		        			</c:if>
		        		</tbody>		        		
		        	</table>
		        	
		        	<div class="page">
					<div id="tr_recommendGrid_pager" class="page_r">
						<ul>
							<li><a href="rechargeMain.jsp?pages=1"><fmt:message key="i18n.firstPage"/></a></li>
							<c:if test="${pageDTO.page!=1}">
								<li><a href="rechargeMain.jsp?pages=${pageDTO.page-1}"><fmt:message key="i18n.upPage"/></a></li>
							</c:if>
							<li><a>${pageDTO.page}/${pageDTO.total}</a></li>
							<c:if test="${pageDTO.page+1<=pageDTO.total}">
								<li><a href="rechargeMain.jsp?pages=${pageDTO.page+1}"><fmt:message key="i18n.nextPage"/></a></li>
							</c:if>
							<li><a href="rechargeMain.jsp?pages=${pageDTO.total}"><fmt:message key="i18n.endPage"/></a></li>
							<li><a><fmt:message key="i18n.total"/>${pageDTO.totalSize}<fmt:message key="i18n.tiao"/></a></li>
						</ul>
					</div>
					</div>
		        	
		        </div>
			</div>  
		        	
</div></div>


<script type="text/javascript" src="../scripts/jquery/jquery-1.4.2.min.js"></script>
<script>

$(function(){
	//showTransRecord('tr_recommend_table','tr_recommend_pager','recommend',1,10,'optDate','desc');
	//showDirectPushUser('tr_recommendGrid_table','tr_recommendGrid_pager','${user.loginName}',1,10,'registerTime','desc');
    $("#doSeach").click(function(){
    	$("#bonusSeachForm").submit();
    });
    $("#bonusTable").find("tr").addClass("color1");
	$("#bonusTable").find("tr:odd").addClass("color2");
})

function checkform(){
	var toMoeny = $('#toMoeny').val();
	if(toMoeny=='' || toMoeny==null){
		alert("Sorry, please enter the amount(对不起，请输入金额)！");
		return false;
	}
	
	if(toMoeny<10){
		alert("Sorry, please input is larger than the amount of 10(对不起，请输入大于10的金额)！");
		return false;
	}
	
}

function checkformPay(){
	if($('#pay_toMoeny').val()==''){
		alert('Please enter the recharge amount(请输入充值金额)!');
		$('#pay_toMoeny').focus();
		return false;
	}
	var toMoeny = $('#pay_toMoeny').val();
	/* if(toMoeny<100){
		alert("The minimum charge for more than 100(最少充值100以上)!");
		return false;
	}
	if(toMoeny % 10 != 0){
		alert('Please enter a multiple of 10(请输入10的倍数)!');
		return false;
	} */ 
}


function toRmb(){
	var toMoeny = $('#pay_toMoeny').val();
	if(toMoeny!='')
	$('#show_toRmb').text("折合人民币:"+toMoeny*1);
}

</script>

</body>
</html>